package com.gz.logistics.library.pojo;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

/**
 * 片区实体
 * author wanner1991
 */
public class PartInfo extends  CustomerSpinnerObject  {
    private int part_id;
    private String part_name;

    public int getPart_id() {
        return part_id;
    }

    public void setPart_id(int part_id) {
        this.part_id = part_id;
    }

    public String getPart_name() {
        return part_name;
    }

    public void setPart_name(String part_name) {
        this.part_name = part_name;
    }

    @Override
    public String toString() {
        return part_name;
    }

    public static List<PartInfo> parse(JSONArray jsonArray) throws JSONException {
        if (jsonArray == null || jsonArray.length() <= 0){
            return null;
        }
        List<PartInfo> parts = new ArrayList<PartInfo>();
        for (int i = 0 ; i < jsonArray.length() ; i ++ ){
            PartInfo part = new PartInfo();
            part.part_id = (jsonArray.getJSONObject(i)).getInt("part_id");
            part.part_name = (jsonArray.getJSONObject(i)).getString("part_name");
            parts.add(part);
        }
        return parts;
    }


}
